# -*- coding: utf-8 -*-

import wx
import wx.xrc


class BenchmarkFolderDialog(wx.Dialog):

    def __init__(self, parent, path=None):
        wx.Dialog.__init__(self, parent, id=wx.ID_ANY, title=u"设置基准文件夹", pos=wx.DefaultPosition, size=wx.DefaultSize,
                           style=wx.DEFAULT_DIALOG_STYLE)

        self.SetSizeHints(wx.DefaultSize, wx.DefaultSize)

        bSizer10 = wx.BoxSizer(wx.VERTICAL)

        self.dirPicker = wx.DirPickerCtrl(self, wx.ID_ANY, wx.EmptyString, u"选择基准文件夹", wx.DefaultPosition,
                                          wx.Size( 450,50 ), wx.DIRP_USE_TEXTCTRL)
        if path:
            self.dirPicker.SetPath(path)
        bSizer10.Add(self.dirPicker, 0, wx.EXPAND | wx.ALL, 5)

        self.b_submit = wx.Button(self, wx.ID_ANY, u"提交", wx.DefaultPosition, wx.DefaultSize, 0)
        bSizer10.Add(self.b_submit, 0, wx.ALIGN_CENTER | wx.ALL, 5)

        self.SetSizer(bSizer10)
        self.Layout()
        bSizer10.Fit(self)

        self.Centre(wx.BOTH)

        # Connect Events
        self.b_submit.Bind(wx.EVT_BUTTON, self.submit)

    def __del__(self):
        pass

    def submit(self, event):
        if self.dirPicker.GetPath():
            self.Parent.set_benchmark_folder(self.dirPicker.GetPath())
            self.Close()